package com.gitee.wsl.security.hash

import com.gitee.wsl.security.digest.Digest

class SHA3(
    bitLength: Int
) : Keccak(bitLength), Digest {
    public constructor() : this(256)

    override val algorithmName: String
        get() = "SHA3-$fixedOutputLength"

    override fun update(byte: Byte): SHA3= apply {
        update(byte)
    }

    override fun update(source: ByteArray, startIndex: Int, endIndex: Int): SHA3 = apply {
        update(source, startIndex, endIndex)
    }

    override fun digest(destination: ByteArray, destinationOffset: Int) {
        absorbBits(0x02, 2)
        super<Keccak>.digest(destination, destinationOffset)
    }
}